package com.qianyu.api.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qianyu.core.entity.base.BaseIdDto;
import com.qianyu.core.entity.base.Result;
import com.qianyu.core.entity.bean.CronTask;
import com.qianyu.core.entity.dto.CornTaskDto;
import com.qianyu.core.service.CornTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "前台管理-执行任务列表", description = "wangzhicheng")
@RestController
@RequestMapping("/front/corn_task")
@RequiredArgsConstructor
public class CornTaskController {

    private final CornTaskService cornTaskService;

    /**
     * 分页查询执行任务列表
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "分页查询执行任务列表")
    Result<Page<CronTask>> pageList(@RequestBody @Validated CornTaskDto.CornTaskPageDto dto) {
        return Result.success(cornTaskService.pageList(dto));
    }

    /**
     * 根据执行任务id获取详情
     */
    @PostMapping("/getInfo")
    @ApiOperation(value = "根据执行任务id获取详情")
    Result<CronTask> getInfo(@RequestBody @Validated BaseIdDto dto){
        return Result.success(cornTaskService.getInfo(dto));
    }
}
